package util

import (
	"fmt"
	"strings"
)

const (
	MD_CONTENT_EXT = ".mdc"
	MD_TOML_EXT    = ".mdt"
	MD_EXT         = ".md"
)

func IsMdContent(s string) bool {
	return strings.HasSuffix(s, MD_CONTENT_EXT)
}

func IsMdToml(s string) bool {
	return strings.HasSuffix(s, MD_TOML_EXT)
}

//生成内容格式
func ToMdContent(name string) string {
	return name + MD_CONTENT_EXT
}

//生成内容toml
func TdMdToml(name string) string {
	return name + MD_TOML_EXT
}

//统一规定markdown格式
func IsMd(name string) bool {
	return strings.HasSuffix(name, MD_EXT)
}

//原文件url
//https://coding.net/u/vco/p/blog/git/raw/master/public/img/logo.jpg
func RawFileUrl(globalKey, project, path string) string {
	return fmt.Sprintf("https://coding.net/u/%s/p/%s/git/raw/%s", globalKey, project, path)
}

//目录树url
func TreeInfoUrl(globalKey, project, path string) string {
	return fmt.Sprintf("https://coding.net/api/user/%s/project/%s/git/treeinfo/%s", globalKey, project, path)
}

//文件url
func FileBlobInfoUrl(globalKey, project, path string) string {
	return fmt.Sprintf("https://coding.net/api/user/%s/project/%s/git/blob/%s", globalKey, project, path)
}
